<?php

/* 
 * File: index.php
 * Author: Tim Kopplow
 * Version 0.12 (Codename: Delicious cheesecake)
 * 
 *
 * GNU General Public License
 *
 * Cake AI is an simple (user generated content) search
 * Copyright (C) 2011  Tim Kopplow
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

########################################
## Mini Lib
########################################
include("config.php");
$thecake = $_GET['c'];
########################################
## MySQL Work
########################################

$abfrage = "SELECT * FROM `content` WHERE begriff = '$thecake' ";
     $ergebnis = mysql_query($abfrage);
     while($row = mysql_fetch_object($ergebnis))
        {
        $begriff.=$row->begriff;
        $content.=$row->content;
        }
########################################
## PHP Work
########################################
if(isset($thecake))
{
$cake_back ="<a href='index.php'>Zurück</a>";
if($thecake == '')
{
  $cake = 'Keine Zutaten, kein Kuchen...';
}
if($thecake != '')
{
// all the actions

    if($thecake != '')
    {
    if($thecake == $begriff)
    {
      $cake = $content;
    }

    
    if($cake == '')
    {
      $cake = "Wow, leider kann ich mit dem Begriff <b><u>$thecake</u></b> nichts anfangen.<br> Bring mir doch bitte bei was du unter diesem Begriff verstehst.<br><br>
      <form action='new_content.php' method='post'>
		<p>Begriff:<br>
		<input type='text' name='begriff' value='$thecake'>
		</p>
		<p>Definition:<br>
		<input type='text' name='def'><br>
		<input type='submit' name='sent' value='Submit'>
		</form>" ;
    }
}
}


$cake_c = $cake;
require('template.php');
}
########################################
## index content erstellen
########################################
if(!isset($thecake))
{
$cake_c="
<form action='$PHP_SELF' method='get'>
Bitte Zutaten <span class='note'>(Suchbegriff)</span> eingeben: <br />
<input type='text' name='c' />
<input class='headbtn' type='submit' value='Backen' />
</form>
<span class='note'><b>Note: Bitte nur kleine Buchstaben benutzen. Große machen den Kuchen so trocken.</b></span><br /><br />
<a href='intro.php'>Was ist Cake AI ?</a><br />
<a href='new_users.php'>Hilfe für neue Benutzer</a> <span style='color:red;font-size:11px;'><b>Empfohlen!</b></span><br /><br />
<a href='new_content.php'><span style='color:red;font-size:20px;'>Definiere einen Begriff!</span></a>
";

require('template.php');
}
?>